package com.yanqu.road.server.cmd.vehiclesoul;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.vehicle.VehicleProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.vehicle.VehicleSoulModule;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.S_VSOUL_OPEN_BLOCK, desc = "魂开孔")
public class VehicleOpenSoulBlockCmd extends AbstractCommand {

	private String vehicleId;

	private int pos;


	@Override
	public boolean parseData(YanQuMessage packet) throws Exception {
		VehicleProto.VehicleOpenSoulBlockReqMsg reqMsg = VehicleProto.VehicleOpenSoulBlockReqMsg.parseFrom(packet.getBytes());
		vehicleId = reqMsg.getVehicleId();
		pos = reqMsg.getPos();
		return true;
	}

	@Override
	public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
		ret = player.getModule(VehicleSoulModule.class).openSoulBlock(vehicleId, pos);
	}

	@Override
	public void sendData(GamePlayer player) {
		VehicleProto.VehicleOpenSoulBlockRespMsg.Builder respMsg = VehicleProto.VehicleOpenSoulBlockRespMsg.newBuilder();
		respMsg.setRet(ret);
		player.sendPacket(Protocol.U_VSOUL_OPEN_BLOCK, respMsg);
	}

}
